/**
 * Created by wzq on 15-3-28.
 */

var mongodb = require('./mongodb.js');
var Schema = mongodb.Schema;

// create a schema
var shareSchema = new Schema({
  // basic_info
  title:String,
  content:String,
  created_at: Date,
  updated_at: {type: Date, default: Date.now},

  // res_info
  resource_list:Array,
  // res_id:String
  // res_type:String, // img, video, doc
  // res_url:String, // url to get it
  // res_desc:String, 
  
  // author_info
  author:Mixed,
  // author_name:String, // show
  // author_id:String, 
  // author_avatar:String, // url

  // comment_info
  comment_count:Number,
  comment_list:Array,
  // comment_date,
  // comment_author_name,
  // comment_author_id,
  // comment_author_avatar,
  // comment_content,
  
  // rank_info
  rank_count:Number,
  rank_value:Number,
  rank_list:Array,
  // rank_date,
  // rank_author_id,
  // rank_value
});

shareSchema.pre('save', function (next) {
  var currentDate = new Date();
  if (!this.created_at) {
    this.created_at = currentDate;
  }
  next();
});

var Share = mongodb.model('Share', shareSchema);

module.exports = Share;